package com.example.comtest;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;

public class MainActivity extends Activity {

	Connection connection;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		
		final EditText commando = (EditText) findViewById(R.id.commando);
		commando.setText("user:password");
		final Button submit = (Button) findViewById(R.id.submit);
		final Button lampOn = (Button) findViewById(R.id.bulb_on);
		final Button lampOff = (Button) findViewById(R.id.bulb_off);

		
		submit.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				connection = new Connection(commando.getText().toString());
				commando.setText("commando sent");
				connection.start();			
				
			}
		});
		
		
		lampOn.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				connection = new Connection("bulb:on");
				commando.setText("bulb:on");
				connection.start();			
			}
		});

		lampOff.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				connection = new Connection("bulb:off");
				commando.setText("bulb:on");
				connection.start();	
			}
		});
		
	}
}
